//
//  ImageViewController.swift
//  DemoProject
//
//  Created by hao on 2018/7/18.
//  Copyright © 2018年 hao. All rights reserved.
//

import UIKit

class ImageViewController: BaseTableViewController {

    lazy var imageView: UIImageView = {
        let _iv = UIImageView(image: UIImage(named: "01"))
        self.tableHeadView.addSubview(_iv)
        _iv.snp.makeConstraints({ (make) in
            make.center.equalTo(self.tableHeadView)
        })
        return _iv
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupData()
        var images = [UIImage]()
        for i in 1...8 {
            images.append(UIImage(named: "0\(i)")!)
        }
        imageView.animationImages = images
        imageView.animationDuration = 0.5
        imageView.animationRepeatCount = 0
        imageView.startAnimating()
    }
    
    // 注意的是在highlighted状态下设置的图片与序列帧动画要显示，必须同时设置UIImageView的状态为highlighted
    private func setupData() {
        let titles = ["image",
                      "highlightedImage",
                      "animationImages",
                      "highlightedAnimationImages",
                      "animationDuration",
                      "animationRepeatCount",
                      "userInteractionEnabled",
                      "highlighted"]
        
        let descArr = ["设置图片，默认显示",
                       "设置高亮状态下显示的图片",
                       "设置序列帧动画的图片数组",
                       "设置高亮状态下序列帧动画的图片数组",
                       "设置序列帧动画播放的时常",
                       "设置序列帧动画播放的次数(0为无限次)",
                       "设置是否允许用户交互，默认不允许用户交互",
                       """
                        设置是否为高亮状态，默认为普通状态
                        注意的是在highlighted状态下设置的图片与序列帧动画要显示，必须同时设置UIImageView的状态为highlighted
                       """]
        
        addTitles(titles, footDescs: descArr)
    }

}
